import { ImageResponse } from 'next/og';
import { Fallback, Wallpaper } from '@/components/brand/og';
import { apiD1, safe } from '@/lib/api';
import { fmtGb, fmtInt, num } from '@/lib/format';
import { routes, SITE_NAME } from '@/lib/site';
export const runtime = 'nodejs';
export const alt = `Artifact on ${SITE_NAME}`;
export const size = { width: 1200, height: 630 };
export const contentType = 'image/png';
export default async function ArtifactOgImage({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
const d = await safe(apiD1.model(slug));
if (!d || d.entity_type !== 'artifact') return new ImageResponse(, { ...size });
const a = d.attributes ?? {};
const counters: [string, string][] = [];
if (typeof a.quant_format === 'string') counters.push(['Format', String(a.quant_format).toUpperCase()]);
if (num(a.file_size_gb) !== null) counters.push(['File size', fmtGb(a.file_size_gb, 1)]);
if (num(a['metric.downloads']) !== null) counters.push(['Downloads', fmtInt(a['metric.downloads'])]);
if (d.organization) counters.push(['Publisher', d.organization.name.slice(0, 18)]);
const kind = d.artifact_kind ?? 'artifact';
return new ImageResponse(, { ...size });
}